package com.woniuxy.woniuticket.notification.util;

import java.util.TimerTask;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.amqp.core.AmqpTemplate;

public class TestTask extends TimerTask{
    private AmqpTemplate amqpTemplate;

    protected final Log logger = LogFactory.getLog(getClass());

    private static boolean isRunning = false;
    String msg="有新的热点消息";

    public TestTask() {
    }

    public TestTask(AmqpTemplate amqpTemplate) {
        this.amqpTemplate = amqpTemplate;
    }

    @Override
    public void run() {
        if (!isRunning) {
            isRunning = true;
//            logger.info("开始执行任务。");
            amqpTemplate.convertAndSend("exchange","a",msg);
            isRunning = false;
//            logger.info("任务执行结束。");

        } else {
//            logger.info("上一次任务执行还未结束，本次任务不能执行。");
        }

    }
}
